/*******************************************************************************
     * File:        gangadsp.c
     * Description: тестовые функции для работы с NDK/JNI, SQLite3, Unicode.
     * Author:      Maer
     * Created:     26 mar 2012
     * SVN-ID:      $Id: gangadsp.c 344 2012-04-04 08:26:11Z dagrs.one $
     * Copyright:   (c) 2012 LabMusic Team
     * Licence:     wxWindows license
     * Email:       dagrs.one@gmail.com
*******************************************************************************/

//#include <stddef.h>
//#include <wchar.h>
#include <android_log.h>

#include "ganga_dsp_HelloNDK.h"

JNIEXPORT jint JNICALL Java_ganga_dsp_HelloNDK_hello (JNIEnv* env, jclass obj) {
	LOGI("Hello NDK!", "This is message from NDK library");
	return 0;
}

JNIEXPORT void JNICALL Java_ganga_dsp_HelloNDK_outlog
  (JNIEnv* env, jclass obj, jstring jMsg)
{
	const char* msg=(*env)->GetStringUTFChars(env, jMsg, 0);
	//printf("Thinking in Java, JNI: %s\n", msg);
	LOGI("%s", msg);
	(*env)->ReleaseStringUTFChars(env, jMsg, msg);
}

/*
JNIEXPORT void JNICALL Java_ganga_dsp_HelloNDK_importFormat
  (JNIEnv* env, jclass obj, jstring dcrFile)
{
    // boolean to determine if string is copied
    jboolean copied;

    // call JNI method to convert jstring to c unicode string
    const jbyte* jchar_dcrFile = (*env)->GetStringUTFChars (env, dcrFile, NULL);
    const wchar_t *unicode = (const wchar_t *) jchar_dcrFile;

    // convert unicode string to c native string using ANSI coding page for converting
    int wlen = wcslen(unicode);
    char *mbDcr = 0;
    int mblen = WideCharToMultiByte(CP_ACP, WC_NO_BEST_FIT_CHARS, unicode, wlen, mbDcr, NULL, NULL, NULL);
    mbDcr = new char[mblen + 1];
    WideCharToMultiByte(CP_ACP, WC_NO_BEST_FIT_CHARS, unicode, wlen, mbDcr, mblen + 1, NULL, NULL);

    // release the string to prevent memory leak
    env->ReleaseStringChars( dcrFile, jchar_dcrFile );

    // now we can work with mbDcr. It contains string in oem charset
    // ...

    delete mbDcr;
}
*/
